package com.leetcode.weekly.contest.no282th;

import java.util.Arrays;

/**
 * @author 覃国强
 * @date 2022-02-27 11:07
 */
public class A03_完成旅途的最少时间 {


  static
  class Solution {
    public long minimumTime(int[] time, int totalTrips) {

      int minTime = Arrays.stream(time).min().getAsInt();

      int[] trips = new int[time.length];
      long answer = 0;
      while (Arrays.stream(trips).sum() < totalTrips) {
        answer += minTime;
        for (int i = 0; i < time.length; ++i) {
          trips[i] = (int) (answer / time[i]);
        }
      }

      return answer;
    }
  }

}
